MolodenskyShift Subroutine

private subroutine MolodenskyShift(a, da, f, df, dx, dy, dz, Lat_in, Lon_in, Hgt_in, WGS84_Lat, WGS84_Lon, WGS84_Hgt)

Uses

shifts geodetic coordinates using the Molodensky method

Arguments

Type IntentOptional Attributes Name
real(kind=float), intent(in) :: a
real(kind=float), intent(in) :: da
real(kind=float), intent(in) :: f
real(kind=float), intent(in) :: df
real(kind=float), intent(in) :: dx
real(kind=float), intent(in) :: dy
real(kind=float), intent(in) :: dz
real(kind=float), intent(in) :: Lat_in
real(kind=float), intent(in) :: Lon_in
real(kind=float), intent(in) :: Hgt_in
real(kind=float), intent(out) :: WGS84_Lat
real(kind=float), intent(out) :: WGS84_Lon
real(kind=float), intent(out) :: WGS84_Hgt

Variables

Type Visibility Attributes Name Initial
real(kind=float), public :: cos_Lat

cos(Latitude_1)

real(kind=float), public :: cos_Lon

cos(Longitude_1)

real(kind=float), public :: dh

Delta height

real(kind=float), public :: dh1

Delta height calculations

real(kind=float), public :: dh2

Delta height calculations

real(kind=float), public :: dl

Delta lambda

real(kind=float), public :: dp

Delta phi

real(kind=float), public :: dp1

Delta phi calculations

real(kind=float), public :: dp2

Delta phi calculations

real(kind=float), public :: dp3

Delta phi calculations

real(kind=float), public :: e2

Intermediate calculations for dp, dl

real(kind=float), public :: ep2

Intermediate calculations for dp, dl

real(kind=float), public :: m

Intermediate calculations for dp, dl

real(kind=float), public :: n

Intermediate calculations for dp, dl

real(kind=float), public :: sin2_Lat

(sin(Latitude_1))^2

real(kind=float), public :: sin_Lat

sin(Latitude_1)

real(kind=float), public :: sin_Lon

sin(Longitude_1)

real(kind=float), public :: tLon_in

temp longitude

real(kind=float), public :: w

Intermediate calculations for dp, dl

real(kind=float), public :: w2

Intermediate calculations for dp, dl

real(kind=float), public :: w3

Intermediate calculations for dp, dl


Source Code

SUBROUTINE MolodenskyShift &
!
(a, da, f, df, dx, dy, dz, Lat_in, Lon_in, &
 Hgt_in, WGS84_Lat, WGS84_Lon, WGS84_Hgt)
 
USE Units, ONLY : pi

IMPLICIT NONE

! Arguments with intent(in):
REAL (KIND = float), INTENT (IN) :: a
REAL (KIND = float), INTENT (IN) :: da
REAL (KIND = float), INTENT (IN) :: f
REAL (KIND = float), INTENT (IN) :: df
REAL (KIND = float), INTENT (IN) :: dx
REAL (KIND = float), INTENT (IN) :: dy
REAL (KIND = float), INTENT (IN) :: dz
REAL (KIND = float), INTENT (IN) :: Lat_in
REAL (KIND = float), INTENT (IN) :: Lon_in
REAL (KIND = float), INTENT (IN) :: Hgt_in

! Arguments with intent(out):
REAL (KIND = float), INTENT (OUT) :: WGS84_Lat
REAL (KIND = float), INTENT (OUT) :: WGS84_Lon
REAL (KIND = float), INTENT (OUT) :: WGS84_Hgt

! Local variables:
REAL (KIND = float) :: tLon_in   !!temp longitude 
REAL (KIND = float) :: e2        !!Intermediate calculations for dp, dl 
REAL (KIND = float) :: ep2       !!Intermediate calculations for dp, dl 
REAL (KIND = float) :: sin_Lat   !!sin(Latitude_1)       
REAL (KIND = float) :: sin2_Lat  !!(sin(Latitude_1))^2   
REAL (KIND = float) :: sin_Lon   !!sin(Longitude_1)      
REAL (KIND = float) :: cos_Lat   !!cos(Latitude_1)       
REAL (KIND = float) :: cos_Lon   !!cos(Longitude_1)      
REAL (KIND = float) :: w2        !!Intermediate calculations for dp, dl 
REAL (KIND = float) :: w         !!Intermediate calculations for dp, dl 
REAL (KIND = float) :: w3        !!Intermediate calculations for dp, dl 
REAL (KIND = float) :: m         !!Intermediate calculations for dp, dl 
REAL (KIND = float) :: n         !!Intermediate calculations for dp, dl 
REAL (KIND = float) :: dp        !!Delta phi             
REAL (KIND = float) :: dp1       !!Delta phi calculations
REAL (KIND = float) :: dp2       !!Delta phi calculations
REAL (KIND = float) :: dp3       !!Delta phi calculations
REAL (KIND = float) :: dl        !!Delta lambda  
REAL (KIND = float) :: dh        !!Delta height  
REAL (KIND = float) :: dh1       !!Delta height calculations 
REAL (KIND = float) :: dh2       !!Delta height calculations 

!------------end of declaration------------------------------------------------

IF (Lon_in > PI) THEN
   tLon_in = Lon_in - (2*PI)
ELSE
   tLon_in = Lon_in
END IF

e2 = 2 * f - f * f
ep2 = e2 / (1 - e2)
sin_Lat = SIN(Lat_in)
cos_Lat = COS(Lat_in)
sin_Lon = SIN(tLon_in)
cos_Lon = COS(tLon_in)
sin2_Lat = sin_Lat * sin_Lat
w2 = 1.0 - e2 * sin2_Lat
w = SQRT(w2)
w3 = w * w2
m = (a * (1.0 - e2)) / w3
n = a / w
dp1 = cos_Lat * dz - sin_Lat * cos_Lon * dx - sin_Lat * sin_Lon * dy
dp2 = ((e2 * sin_Lat * cos_Lat) / w) * da
dp3 = sin_Lat * cos_Lat * (2.0 * n + ep2 * m * sin2_Lat) * (1.0 - f) * df
dp = (dp1 + dp2 + dp3) / (m + Hgt_in)
dl = (-sin_Lon * dx + cos_Lon * dy) / ((n + Hgt_in) * cos_Lat)
dh1 = (cos_Lat * cos_Lon * dx) + (cos_Lat * sin_Lon * dy) + (sin_Lat * dz)
dh2 = -(w * da) + ((a * (1 - f)) / w) * sin2_Lat * df
dh = dh1 + dh2
WGS84_Lat = Lat_in + dp
WGS84_Lon = Lon_in + dl
WGS84_Hgt = Hgt_in + dh
IF (WGS84_Lon > (PI * 2)) THEN
   WGS84_Lon = WGS84_Lon - 2*PI
END IF
IF (WGS84_Lon < (- PI)) THEN
   WGS84_Lon = WGS84_Lon + 2*PI
END IF

END SUBROUTINE MolodenskyShift